package com.nanfang51g3.ckz.http;

import rx.Observable;
import rx.functions.Func1;
import rx.functions.Func2;

/**
 * Created by Administrator on 2016/5/7.
 */
public class RetryWithDelayIf implements Func1<Observable<? extends Throwable>, Observable<?>> {
    private final int maxRetries;
    private final int retryDelayMillis;
    private int retryCount;
    private Func1<Throwable, Boolean> retryIf;

    public RetryWithDelayIf(final int maxRetries, final int retryDelayMillis, Func1<Throwable, Boolean> retryIf) {
        this.maxRetries = maxRetries;
        this.retryDelayMillis = retryDelayMillis;
        this.retryCount = 0;
        this.retryIf = retryIf;
    }


    @Override
    public Observable<?> call(Observable<? extends Throwable> attempts) {
        return attempts.zipWith( Observable.range(1, 5), new Func2<Throwable, Integer, Integer>() {
            @Override
            public Integer call(Throwable throwable, Integer i) {

                return i;
            }
        }).flatMap(new Func1<Integer, Observable<?>>() {
            @Override
            public Observable<?> call(Integer integer) {
                    return null;
            }
        });
    }
}
